//
// Created by 莫吉米 on 16/8/9.
//
#include <string>
#include <iostream>
#include <istream>
#include <fstream>

using namespace std;
#include "Config.h"

/*
 * class Config {
public:
    static string host;
    static string user;
    static string passwd;
    static string db;
    static int    port;
public:
    Config(string path);
};
 */

Config::Config(string path)
{
    ifstream instream;
    instream.open(path);
    //cout<<"Open"<<endl;
    string option;
    if(instream)
        cout<<"Open"<<endl;
    while(instream>>option)
    {
        cout<<option<<endl;
        if(option == "HOST")
        {
            instream>>host;
        }
        else if(option == "USER")
        {
            instream>>user;
        }
        else if(option == "PASSWORD")
        {
            instream>>passwd;
        }
        else if(option == "DATABASE")
        {
            instream>>db;
        }
        else if(option == "PORT")
        {
            instream>>port;
        }
        else
            cerr<<"No config option: "<<option<<endl;
    }

}


